import sys
from brisque_dmos import *
import joblib
import cv2


i = 1  # user sets it to take assessed image
pre_img_path = 'F:/LIVE_DB/database_v2/jpeg/img' + str(i) + '.bmp'
X = []
# read image from given path
img = cv2.imread(pre_img_path, 1)
if img is None:
    print("Wrong image path given")
    print("Exiting...")
    sys.exit(0)
# convert to gray scale
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# compute feature vectors of the image
feat = brisque_feature(img)
size = img.shape
# down sampling
img = cv2.resize(img, (int(size[1] / 2), int(size[0] / 2)), cv2.INTER_NEAREST)
feat = feat + brisque_feature(img)
X.append(feat)

clf = joblib.load('dmos_model.m')
score = clf.predict(X)
print(score)
